﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using Easy.Model;

namespace Easy.Operation.Data
{
    public class PageView
    {
        public string EntityName;
        public string ViewName;
        public Dictionary<string, Field> Fields;
        //public Dictionary<string, Field> FieldsAll;
        public Dictionary<string, List<OptionSet>> Options;
        public List<ViewModel> ViewsPC = new List<ViewModel>();
        public List<ViewModel> ViewsMO = new List<ViewModel>();
        public Privilege UserPrivilege;
        public List<string> FunctionPrivilege;


        public PageView(string entityname, SystemUserModel user, string viewname)
        {
            this.EntityName = entityname;

            Core core = new Core(EntityName);
            //this.FieldsAll = core.GetViewFields(); //modify:kyzhao 视图取字段使用GetViewFields方法

            List<ViewModel>  Views = core.GetViewsData();
            foreach(ViewModel view in Views)
            {
                if(view.ClientType==10)
                {
                    ViewsPC.Add(view);
                }
                else
                {
                    ViewsMO.Add(view);
                }
            }

            this.ViewName = viewname;
            
            this.Fields = core.GetViewFields(this.ViewName);//modify:kyzhao 视图取字段使用GetViewFields方法
            this.Options = core.GetEntityOptions(this.ViewName);

            this.UserPrivilege = core.GetPrivilege(user.SystemUserId);

            this.FunctionPrivilege = core.GetOprivilege(user.SystemUserId);


        }
                   

    }
}